/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.time.LocalDate;
import java.util.Random;

/**
 * <p>Project: javase2203 - Switch5
 * <p>Powered by webrx On 2022-07-14 09:21:24
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Switch5 {
    public static void main(String[] args) {
        //最新switch语句
        Random rand = new Random();
        //switch表达式 java12
        int yy = rand.nextInt(2000, 2023);
        int mm = rand.nextInt(1, 13);
        System.out.printf("%d年%02d月%n",yy,mm);
        switch (mm) {
            case 2 -> System.out.println(LocalDate.of(yy, mm, 1).isLeapYear() ? 29 : 28);
            case 4, 6, 9, 11 -> System.out.println(30);
            default -> {
                System.out.println(31);
                System.out.println(31);
                System.out.println(31);
            }
        }
    }
}
